home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************************
- ********************************************************************************
- ********************************************************************************
-
- PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
- THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
-
- P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
-
-
- ********************************************************************************
- ********************************************************************************
- *******************************************************************************/
-
- #include "header.h"
- #include "ships.h"
-
- processinput(cp,ptrnoofchars)
- register struct player *cp;
- long *ptrnoofchars;
- {
- register struct player *x,*o;
- int z;
- unsigned char c; /* override "char c" in header.h -- br */
-
- getbuf(cp,ptrnoofchars);
- while ((c=getchr(cp))!='\0')
- {
- if (c=='+')
- {
- plot1(cp,"Self Destruct Activated!!!!!!!!!!!!! Abandon Ship........");
- plot2(cp,"Abandon Ship..Abandon Ship..Abandon Ship...........Aaargh");
- if (cp->reason>0) cp->reason= -3;
- finish(cp);
- continue;
- }
- if (c=='G')
- { if (cp->beeping)
- {
- cp->beeping=OFF;
- plot1(cp," Beep switched off. ");
- plot2(cp," ");
- }
- else
- {
- cp->beeping=ON;
- plot1(cp," Beep switched on. ");
- plot2(cp," ");
- beep(cp);
- }
- continue;
- }
- if (((c=='?'))&&(cp->stat!=0)&&(cp->stat!=1)&&(cp->stat!=6)&&(cp->stat<9)&&(cp->stat!=5))
- {
- cp->xvel=0;
- cp->yvel=0;
- cp->oldstat=cp->stat;
- plotstatus(cp,11);
- display_sheet(cp);
- continue;
- }
-
-
- if ((cp->stat==11)||(cp->stat==10))
- {
- drawcross(cp);
- if (cp->stat==10) {
- updateship(cp);
- cp->score+=10;
- plotscore(cp);
- }
- plotstatus(cp,cp->oldstat);
- continue;
- }
-
- if (cp->stat==1)
- {
- if ((c!='\n') && (cp->messindex<6))
- {
- cp->message[cp->messindex]=c;
- poscurs(cp,(69+cp->messindex),22);
- write(cp->fd,&c,1);
- ++(cp->messindex);
- continue;
- }
- else
- {
- c=cp->message[0];
- if (c==ROMID || c==(ROMID+32))
- {
- plot1(cp," Since when do Romulan ships have prefix codes? ");
- plot2(cp," ");
- plotstatus(cp,cp->oldstat);
- continue;
- }
- if (c==KLINGID || c==(KLINGID+32))
- {
- plot1(cp," Since when do Klingon ships have prefix codes? ");
- plot2(cp," ");
- plotstatus(cp,cp->oldstat);
- continue;
- }
- x=startlist;
- o=NULL;
- while (x!=NULL)
- {
- if ((c==x->id)||(c==(char)(x->id+32)))
- {
- o=x;
- x=NULL;
- } else
- x=x->next;
- }
- if (o==NULL)
- {
- plot1(cp," Uhura : Unknown destination ship sir. ");
- plot2(cp," (The player probably died recently.) ");
- plotstatus(cp,cp->oldstat);
- continue;
- } else
- {
- j=1;
- for (i=0;i<5;++i)
- if (cp->message[j]!=ship[o->shipno].prefixcode[i]) j=15;
- else ++j;
- if ((o->shipno)>24) {i=15; j=15;}
- if (j==15)
- {
- if (i!=15)
- {
- plot1(cp," Uhura : That prefix code didn't work sir. ");
- plot2(cp," We must have the wrong combination...... ");
- } else
- {
- plot1(cp," Spock : We cannot lower the shields of this ");
- plot2(cp," alien vessel, as it does not have a prefix code. ");
- }
- plotstatus(cp,cp->oldstat);
- continue;
- } else
- {
- plot1(cp," Uhura : prefix code sent sir. ");
- plot2(cp," Spock : It seems to work sir. ");
- plot1(o,"Spock : Our shields and cloaking device are dropping.... ");
- plot2(o," It looks like our ship received its prefix code! ");
- o->cloakingdevice=OFF;
- o->shields=OFF;
- if (o->id<72) o->id=(char)(o->id+32);
- plotshields(o);
- plotcloakingdevice(o);
- if (o->stat<12) o->chflg=FLAG;
- plotstatus(cp,cp->oldstat);
- continue;
- }
- }
- }
- }
-
- if (cp->stat==0)
- {
- if ((c!='\n') && (cp->messindex<57))
- {
- cp->message[cp->messindex]=c;
- poscurs(cp,(20+cp->messindex),22);
- write(cp->fd,&c,1);
- ++(cp->messindex);
- continue;
- }
- else
- {
- c=cp->message[0];
- if ((c==(ROMID+32))||(c==(KLINGID+32))||(c==ROMID)||(c==KLINGID))
- {
- plot1(cp," Uhura : I cannot contact enemy captain. ");
- plot2(cp," They are jamming all frequencies....... ");
- plotstatus(cp,cp->oldstat);
- continue;
- }
- x=startlist;
- o=NULL;
- while (x!=NULL)
- {
- if ((c==x->id)||(c==(char)(x->id+32)))
- {
- o=x;
- x=NULL;
- } else
- x=x->next;
- }
- if (o==NULL)
- {
- plot1(cp," Uhura : Unknown destination ship sir. ");
- plot2(cp," (The player probably died recently.) ");
- plotstatus(cp,cp->oldstat);
- continue;
- } else
- {
- plot1(cp," Uhura : Message sent sir. ");
- plot2(cp," ");
- plot1(o," Uhura : Message from the ");
- poscurs(o,46,21);
- write(o->fd,ship[cp->shipno].name,27);
- poscurs(o,70,21);
- write(o->fd,"(",1);
- c=cp->id;
- if ((c>=65)&&(c<=90)) c+=32;
- poscurs(o,71,21);
- write(o->fd,&c,1);
- poscurs(o,72,21);
- write(o->fd,")",1);
- cp->message[0]=' ';
- plot2(o,cp->message);
- plotstatus(cp,cp->oldstat);
- continue;
- }
- }
- }
-
- if (cp->stat==9)
- {
- if (c=='S') {drawcross(cp); plotstatus(cp,cp->oldstat); continue;}
- if ((c>=97)&&(c<=128))
- {
- o=NULL;
- x=startlist;
- while (x!=NULL)
- {
- if ((c==x->id)||(c==((char)(x->id)+32)))
- {
- o=x;
- x=NULL;
- } else x=x->next;
- }
- if (o==NULL)
- {
- plot1(cp," There is no such ship in scanning range. ");
- plot2(cp," Scan cancelled. Use 'S' to abort Scan. ");
- continue;
- } else
- {
- if ((o->id!=ROMID)&&(o->id!=KLINGID)&&(o->shields))
- {
- plot1(cp," We cannot scan through another ships shields. ");
- plot2(cp," Scan cancelled. Use 'S' to abort Scan. ");
- }
- else scan(cp,o);
- }
- }
- }
- if (cp->stat==6)
- {
- switch (c)
- {
- case '1':lock_on(cp,0); break;
- case '2':lock_on(cp,1); break;
- case '3':lock_on(cp,2); break;
- case '4':lock_on(cp,3); break;
- default:
- plot1(cp," Invalid tractor beam number! ");
- plot2(cp," ");
- break;
- }
- plotstatus(cp,3);
- continue;
- }
-
- if (cp->stat==5)
- {
- cp->flyto= -1;
- switch (c) {
- case '1' : cp->flyto=0; break;
- case '2' : cp->flyto=1; break;
- case '3' : cp->flyto=2; break;
- case '4' : cp->flyto=3; break;
- default :
- {
- plot1(cp," Invalid Channel number. ");
- plot2(cp," Auto-Pilot Cancelled. ");
- cp->xvel=0;
- cp->yvel=0;
- cp->flyto= -1;
- plotvelocity(cp);
- plotstatus(cp,3);
- break;
- }
- }
- z=cp->flyto;
- if ((z>=0)&&(z<=3)&&(cp->channel[z].xloc==0)&&(cp->channel[z].yloc==0)&&(cp->channel[z].enemy==NULL))
- {
- plot1(cp," That beam isn't programmed. ");
- plot2(cp," Auto-Pilot Cancelled. ");
- cp->xvel=0;
- cp->yvel=0;
- cp->flyto= -1;
- plotvelocity(cp);
- plotstatus(cp,3);
- }
- continue;
- }
-
-
- if(((cp->stat>1)&&(cp->stat<5))||(cp->stat==7)||(cp->stat==8))
- {
- switch (c) {
- case 'l':if (cp->stat>6) {move_message(cp); break;}
- ++(cp->xvel); if (cp->stat<12) cp->chflg=FLAG;
- checkvelocity(cp);
- break;
- case 'k':if (cp->stat>6) {move_message(cp); break;}
- ++(cp->yvel); if (cp->stat<12) cp->chflg=FLAG;
- checkvelocity(cp);
- break;
- case 'j':if (cp->stat>6) {move_message(cp); break;}
- --(cp->yvel); if (cp->stat<12) cp->chflg=FLAG;
- checkvelocity(cp); break;
- case 'h':if (cp->stat>6) {move_message(cp); break;}
- --(cp->xvel); if (cp->stat<12) cp->chflg=FLAG;
- checkvelocity(cp); break;
- case 'y':if (cp->stat>6) {move_message(cp); break;}
- --(cp->xvel); ++(cp->yvel); if (cp->stat<12)
- cp->chflg=FLAG; checkvelocity(cp); break;
- case 'b':if (cp->stat>6) {move_message(cp); break;}
- --(cp->xvel); --(cp->yvel); if (cp->stat<12)
- cp->chflg=FLAG; checkvelocity(cp); break;
- case 'n':if (cp->stat>6) {move_message(cp); break;}
- ++(cp->xvel); --(cp->yvel); if (cp->stat<12)
- cp->chflg=FLAG; checkvelocity(cp); break;
- case 'u':if (cp->stat>6) {move_message(cp); break;}
- ++(cp->xvel); ++(cp->yvel); if (cp->stat<12)
- cp->chflg=FLAG; checkvelocity(cp); break;
- case 's':if (cp->stat>6) {move_message(cp); break;}
- cp->xvel=0; cp->yvel=0; if (cp->stat<12)
- cp->chflg=FLAG; checkvelocity(cp);
- plotvelocity(cp); break;
- case 'L':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel=1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'H':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel= -1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'J':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->yvel= -1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'K':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->yvel=1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'Y':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel= -1;
- cp->yvel= 1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'U':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel=1;
- cp->yvel=1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'B':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel= -1;
- cp->yvel= -1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'N':
- if (cp->xvel!=0 || cp->yvel!=0) {impulse_message(cp); break;}
- if (cp->stat>6) {move_message(cp); break;}
- cp->xvel= 1;
- cp->yvel= -1;
- cp->impulsemove=1;
- if (cp->stat<12) cp->chflg=FLAG;
- break;
- case 'p': if (cp->weaponselect==0)
- {
- cp->weaponselect=1;
- plot1(cp," ");
- plot2(cp," Photon Torpedos ready Captain!! ");
- }
- else
- {
- cp->weaponselect=0;
- plot1(cp," Locking Phasers Captain! ");
- plot2(cp," ");
- }
- plotphaserbanks(cp);
- plotphotontorpedos(cp);
- break;
- case 'D': if (debug) debug=OFF; else debug=ON;
- break;
- case 'c': { if (cp->cloakingdevice)
- {
- cp->cloakingdevice=OFF;
- }
- else
- {
- if ((which_sector(cp->xpos,cp->ypos,cp->xvel,cp->yvel)==3))
- {
- plot1(cp," You are in the Mutara Nebula!! ");
- plot2(cp," Cloaking Device is inoperative! ");
- } else
- {
- if (storm)
- {
- plot1(cp," That ion storm is still out there. ");
- plot2(cp," We cannot cloak while it's around. ");
- } else
- {
- if (cp->stat<7)
- {
- cp->cloakingdevice=ON;
- cp->clflg=ON;
- }
- }
- }
- }
- if (cp->stat<12) cp->chflg=FLAG;
- plotcloakingdevice(cp);
- break;
- }
- case 'z':
- if (cp->stat==8) { beamdown(cp); } else
- {
- plot1(cp," We are not in orbit !! ");
- plot2(cp," ");
- }
- break;
- case 'v': { if (cp->shields)
- {
- cp->shields=OFF;
- cp->id=(char)(cp->id+32);
- }
- else
- {
- if ((which_sector(cp->xpos,cp->ypos,cp->xvel,cp->yvel)==3))
- {
- plot1(cp," You are in the Mutara Nebula!! ");
- plot2(cp," Shields are inoperative! ");
- } else
- {
- if (cp->stat<7)
- {
- cp->shields=ON;
- cp->id=(char)(cp->id-32);
- }
- }
- }
- if (cp->stat<12) cp->chflg=FLAG;
- plotshields(cp);
- break;
- }
- case 'W': {
- x=startlist;
- plot1(cp,"Starfleet says that the following ships exist as well : ");
- plot2(cp," ");
- poscurs(cp,30,22);
- while (x!=NULL)
- {
- if (x==cp) { x=x->next; continue;}
- write(cp->fd,&(x->id),1);
- write(cp->fd," ",2);
- x=x->next;
- }
- break;
- }
- case 'q': plotposition(cp);
- break;
- case 'a':
- if (cp->stat>6) {move_message(cp); break;}
- plotstatus(cp,5);
- cp->xvel=0;
- cp->yvel=0;
- plot1(cp," Where to? (1,2,3 or 4) ");
- plot2(cp," ");
- displaybeams(cp);
- plotvelocity(cp);
- break;
- case 't': if ((cp->stat==7)||(cp->stat==8))
- {
- lockmessage(cp);
- break;
- } else
- plotstatus(cp,6);
- plot1(cp," Which tractor beam? (1,2,3 or 4) Currently they are : ");
- plot2(cp," ");
- displaybeams(cp);
- break;
- case 'T':
- plot1(cp,"Tractor beams are currently locked on to the following : ");
- plot2(cp," ");
- displaybeams(cp);
- break;
- case 'P':
- cp->oldstat=cp->stat;
- plotstatus(cp,1);
- plot1(cp,"To transmit enemy prefix code type the ships letter ");
- plot2(cp,"followed by the 5 digit prefix code and return : ");
- for (i=0;i<57;++i)
- cp->message[i]=' ';
- cp->messindex=0;
- break;
- case 'C':
- cp->oldstat=cp->stat;
- plotstatus(cp,0);
- plot1(cp,"Uhura :Type ship letter & 56 chars (max) message & return");
- plot2(cp," ");
- for (i=0;i<57;++i)
- cp->message[i]=' ';
- cp->messindex=0;
- break;
- case 'w': plotvelocity(cp);
- break;
- case 'e': plotenergy(cp);
- break;
- case 'd': if (cp->stat!=7) dock(cp);
- break;
- case 'f': undock(cp);
- break;
- case 'S':
- cp->xvel=0; cp->yvel=0;
- cp->oldstat=cp->stat;
- plotstatus(cp,9);
- plot1(cp," Which Ship ? ");
- plot2(cp," ");
- break;
- case 'o': orbit(cp);
- break;
- case 'i': unorbit(cp);
- break;
- case 'R': cp->oldstat=cp->stat;
- redrawconsole(cp);
- plotstatus(cp,cp->oldstat);
- break;
- case '1': fire_torpedo(cp,c,0); break;
- case '4': fire_torpedo(cp,c,0); break;
- case '7': fire_torpedo(cp,c,0); break;
- case '8': fire_torpedo(cp,c,0); break;
- case '9': fire_torpedo(cp,c,0); break;
- case '6': fire_torpedo(cp,c,0); break;
- case '3': fire_torpedo(cp,c,0); break;
- case '2': fire_torpedo(cp,c,0); break;
- default :
- {
- plot1(cp," That key isn't in use! ");
- plot2(cp," ");
- beep(cp); break;
- }
- } /*switch*/
- } /*if - then*/
- } /*while loop*/
- }
-
- move_message(cp)
- register struct player *cp;
- {
- if (cp->stat==7)
- {
- plotvelocity(cp);
- plot1(cp," You can't move when you're docked captain! Press ");
- plot2(cp," f to undock. Will you ever get the hang of this? ");
- }
- if (cp->stat==8)
- {
- plotvelocity(cp);
- plot1(cp," You can't leave orbit just like that. We need reverse ");
- plot2(cp," impulse thrusters to get out. Press 'i' to kill orbit. ");
- }
- }
-
- impulse_message(cp)
- register struct player *cp;
- {
- plotvelocity(cp);
- plot1(cp," Manoevering Impulse Thrusters only function from ");
- plot2(cp," a stationary position..thrusters are overheated. ");
- }
-
- lockmessage(cp)
- register struct player *cp;
- {
- plot1(cp,"You can't lock tractor beams when you're docked or in ");
- plot2(cp," orbit. Will you ever get the hang of this? ");
- }
-
- checkvelocity(cp)
- register struct player *cp;
- {
- if ((abs(cp->xvel)>cp->maxvel)||(abs(cp->yvel)>cp->maxvel))
- {
- plot1(cp," Scott to Captain: The dilithium crystals are melting! ");
- plot2(cp," I canna make 'er go faster than that Captain. ");
- if (abs(cp->xvel)>cp->maxvel)
- {
- if (cp->xvel<0) ++(cp->xvel); else --(cp->xvel);
- } else
- {
- if (cp->yvel<0) ++(cp->yvel); else --(cp->yvel);
- }
- }
- }
-